/*
 * Copyright 2009 Colin Prinn
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package net.recursv.motific.at.scene;

import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import java.util.Vector;

/**
 * Created by: recursv
 * Date: 9/08/2009
 * Time: 8:47:13 AM
 */
public class GraphicsWrapper {

    private Graphics _g;

    private Vector _tasks = new Vector();

    GraphicsWrapper() {
    }

    public Vector getTasks() {
        return _tasks;
    }

    private void addTask(String name, int x, int y, int w, int h, String text) {
        GraphicsTask task = new GraphicsTask(name);
        task.setX(x);
        task.setY(y);
        task.setWidth(w);
        task.setHeight(h);
        task.setColor(_g.getColor());
        task.setText(text);
        _tasks.addElement(task);
    }

    public void setGraphics(Graphics graphics) {
        _g = graphics;
    }

    public void clear() {
        _tasks.removeAllElements();
    }

    public int getTranslateY() {
        return _g.getTranslateY();
    }

    public int getColor() {
        return _g.getColor();
    }

    public int getRedComponent() {
        return _g.getRedComponent();
    }

    public int getGreenComponent() {
        return _g.getGreenComponent();
    }

    public int getBlueComponent() {
        return _g.getBlueComponent();
    }

    public int getGrayScale() {
        return _g.getGrayScale();
    }

    public void setColor(int i, int i1, int i2) {
        _g.setColor(i, i1, i2);
    }

    public void setColor(int i) {
        _g.setColor(i);
    }

    public void setGrayScale(int i) {
        _g.setGrayScale(i);
    }

    public Font getFont() {
        return _g.getFont();
    }

    public void setStrokeStyle(int i) {
        _g.setStrokeStyle(i);
    }

    public int getStrokeStyle() {
        return _g.getStrokeStyle();
    }

    public void setFont(Font font) {
        _g.setFont(font);
    }

    public int getClipX() {
        return _g.getClipX();
    }

    public int getClipY() {
        return _g.getClipY();
    }

    public int getClipWidth() {
        return _g.getClipWidth();
    }

    public int getClipHeight() {
        return _g.getClipHeight();
    }

    public void clipRect(int i, int i1, int i2, int i3) {
        _g.clipRect(i, i1, i2, i3);
    }

    public void setClip(int i, int i1, int i2, int i3) {
        _g.setClip(i, i1, i2, i3);
    }

    public void drawLine(int i, int i1, int i2, int i3) {
        _g.drawLine(i, i1, i2, i3);
    }

    public void fillRect(int x, int y, int w, int h) {
        _g.fillRect(x, y, w, h);
        addTask("fillRect", x, y, w, h, "");
    }

    public void drawRect(int x, int y, int w, int h) {
        _g.drawRect(x, y, w, h);
        addTask("drawRect", x, y, w, h, "");
    }

    public void drawRoundRect(int i, int i1, int i2, int i3, int i4, int i5) {
        _g.drawRoundRect(i, i1, i2, i3, i4, i5);
    }

    public void fillRoundRect(int i, int i1, int i2, int i3, int i4, int i5) {
        _g.fillRoundRect(i, i1, i2, i3, i4, i5);
    }

    public void fillArc(int i, int i1, int i2, int i3, int i4, int i5) {
        _g.fillArc(i, i1, i2, i3, i4, i5);
    }

    public void drawArc(int i, int i1, int i2, int i3, int i4, int i5) {
        _g.drawArc(i, i1, i2, i3, i4, i5);
    }

    public void drawString(String s, int x, int y, int offset) {
        _g.drawString(s, x, y, offset);
        addTask("drawString", x, y, _g.getFont().stringWidth(s), _g.getFont().getHeight(), s);
    }

    public void drawSubstring(String s, int i, int i1, int i2, int i3, int i4) {
        _g.drawSubstring(s, i, i1, i2, i3, i4);
    }

    public void drawChar(char c, int i, int i1, int i2) {
        _g.drawChar(c, i, i1, i2);
    }

    public void drawChars(char[] chars, int i, int i1, int i2, int i3, int i4) {
        _g.drawChars(chars, i, i1, i2, i3, i4);
    }

    public void drawImage(Image image, int i, int i1, int i2) {
        _g.drawImage(image, i, i1, i2);
    }

    public void drawRegion(Image image, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
        _g.drawRegion(image, i, i1, i2, i3, i4, i5, i6, i7);
    }

    public void copyArea(int i, int i1, int i2, int i3, int i4, int i5, int i6) {
        _g.copyArea(i, i1, i2, i3, i4, i5, i6);
    }

    public void fillTriangle(int i, int i1, int i2, int i3, int i4, int i5) {
        _g.fillTriangle(i, i1, i2, i3, i4, i5);
    }

    public void drawRGB(int[] ints, int i, int i1, int i2, int i3, int i4, int i5, boolean b) {
        _g.drawRGB(ints, i, i1, i2, i3, i4, i5, b);
    }

    public int getDisplayColor(int i) {
        return _g.getDisplayColor(i);
    }
}
